//
// Created by admin on 2022/1/5.
//

//#include <stdexcept>
#include "SequenceList.h"

template <class E>
SequenceList<E>::SequenceList(int capacity) {
    p_capacity = capacity;
    p_size = 0;
    p_elements = new E[capacity];
}

template<class E>
SequenceList<E>::~SequenceList() {
    delete[] p_elements;

}

template<class E>
bool SequenceList<E>::rangeCheck(int index) {
//    if (index >= p_size)
//        throw std::range_error("超出范围");
    return false;
}

template<class E>
E SequenceList<E>::get(int index) {
    rangeCheck(index);
    return p_elements[index];
}

template<class E>
bool SequenceList<E>::add(E element) {
    // TODO 检查容量
    p_elements[p_size++] = element;
    return true;
}

